<?php declare(strict_types=1);
/**
 * @author      xianganyall <xianganyall@gmail.com>
 * @copyright   2023-2025 owner
 **/

namespace Srv\Libs\ConfModel;

final class RouteConf extends ConfAbstract
{
    public const PREFIX                         = 'ROUTE.';             // 配置前缀[必定点结尾]
    public const GROUP_KEY                      = 'appKey';             // 分组值唯一字段名
    private string $groupName                   = '';                   // 分组名
    protected int $allowDiffTime                = 180;                  // 允许的时间差[秒][header校验使用]
    protected int $recordLevel                  = 0;                    // 记录运行等级[0-不记录,1-全记录,2-记录失败和运行慢]
    protected int $recordSlowTimeMill           = 0;                    // 运行慢时长[毫秒][0-不记录运行慢]
    protected string $appKey                    = '';                   // 应用Key
    protected string $appSecret                 = '';                   // 应用Secret
    protected bool $sigSkip                     = false;                // 是否允许跳过签名校验
    protected string $sigSkipSecret             = '';                   // 跳过签名Secret
    protected bool $reqHeaderFromCookie         = false;                // 请求头允许Cookie补充[Socks时仅首次]
    protected bool $reqHeaderFromGet            = false;                // 请求头允许Get补充[Socks时仅首次]
    protected bool $reqHeaderCheck              = false;                // 请求头检查[Socks时仅首次][优先级:header>cookie>get]
    protected bool $reqContentSig               = false;                // 请求签名[Socks时仅首次]
    protected string $reqContentSecret          = 'NONE';               // 请求加密[NONE-不加密,RAND-随即密钥,或固定密钥16位][默认-NONE]
    protected string $reqContentType            = 'FROM';               // 请求格式[JSON,XML,PROTOBUF,FROM][默认-FROM]
    protected bool $webSocket                   = false;                // 是否是Socks模式
    protected bool $webSocketAuth               = false;                // 是否Socks认证成功才连接[仅Socks支持]
    protected bool $rspContentSig               = false;                // 响应签名[Socks不支持]
    protected string $rspContentSecret          = 'NONE';               // 响应加密[NONE-不加密,RAND-随即密钥,或固定密钥16位][默认-NONE]
    protected string $rspContentType            = 'HTML';               // 响应格式[JSON,XML,PROTOBUF,BINARY,TEXT,HTML][默认-HTML]
    protected string $smartyException           = '';                   // smartyException[NONE-空内容,空字符串时-错误响应头代码]
    protected string $smartyError               = '';                   // smartyError[NONE-空内容,空字符串时-错误响应头代码]
    protected string $smartyNotFound            = '';                   // smartyNotFound[NONE-空内容,空字符串时-错误响应头代码]
    protected string $smartyNoPermission        = '';                   // smartyNoPermission[NONE-空内容,空字符串时-错误响应头代码]
    protected string $smartyParamFail           = '';                   // smartyParamFail[NONE-空内容,空字符串时-错误响应头代码]
    protected string $actionNotFoundRequest     = '';                   // 请求未找到执行当前组内path[当配置执行返回非True,将继续执行响应]
    protected string $actionNotPermission       = '';                   // 请求无权限执行当前组内path[当配置执行返回非True,将继续执行响应]
    protected array $actions                    = [];                   // 模块列表
    protected array $actionPaths                = [];                   // 模块目录列表

    /**
     * @param array $confData
     * @param string $groupName
     */
    public function __construct(array $confData, string $groupName)
    {
        $this->init($confData);
        $this->groupName = $groupName;
    }

    /**
     * @return string
     */
    public function getGroupName(): string
    {
        return $this->groupName;
    }

    /**
     * @return int
     */
    public function getAllowDiffTime(): int
    {
        return $this->allowDiffTime;
    }

    /**
     * @return int
     */
    public function getRecordLevel(): int
    {
        return $this->recordLevel;
    }

    /**
     * @return int
     */
    public function getRecordSlowTimeMill(): int
    {
        return $this->recordSlowTimeMill;
    }

    /**
     * @return string
     */
    public function getAppKey(): string
    {
        return $this->appKey;
    }

    /**
     * @return string
     */
    public function getAppSecret(): string
    {
        return $this->appSecret;
    }

    /**
     * @return bool
     */
    public function isSigSkip(): bool
    {
        return $this->sigSkip;
    }

    /**
     * @return string
     */
    public function getSigSkipSecret(): string
    {
        return $this->sigSkipSecret;
    }

    /**
     * @return bool
     */
    public function isReqHeaderFromCookie(): bool
    {
        return $this->reqHeaderFromCookie;
    }

    /**
     * @return bool
     */
    public function isReqHeaderFromGet(): bool
    {
        return $this->reqHeaderFromGet;
    }

    /**
     * @return bool
     */
    public function isReqHeaderCheck(): bool
    {
        return $this->reqHeaderCheck;
    }

    /**
     * @return bool
     */
    public function isReqContentSig(): bool
    {
        return $this->reqContentSig;
    }

    /**
     * @return string
     */
    public function getReqContentSecret(): string
    {
        return $this->reqContentSecret;
    }

    /**
     * @return string
     */
    public function getReqContentType(): string
    {
        return $this->reqContentType;
    }

    /**
     * @return bool
     */
    public function isWebSocket(): bool
    {
        return $this->webSocket;
    }

    /**
     * @return bool
     */
    public function isWebSocketAuth(): bool
    {
        return $this->webSocketAuth;
    }

    /**
     * @return bool
     */
    public function isRspContentSig(): bool
    {
        return $this->rspContentSig;
    }

    /**
     * @return string
     */
    public function getRspContentSecret(): string
    {
        return $this->rspContentSecret;
    }

    /**
     * @return string
     */
    public function getRspContentType(): string
    {
        return $this->rspContentType;
    }

    /**
     * @return string
     */
    public function getSmartyException(): string
    {
        return $this->smartyException;
    }

    /**
     * @return string
     */
    public function getSmartyError(): string
    {
        return $this->smartyError;
    }

    /**
     * @return string
     */
    public function getSmartyNotFound(): string
    {
        return $this->smartyNotFound;
    }

    /**
     * @return string
     */
    public function getSmartyNoPermission(): string
    {
        return $this->smartyNoPermission;
    }

    /**
     * @return string
     */
    public function getSmartyParamFail(): string
    {
        return $this->smartyParamFail;
    }

    /**
     * @return string
     */
    public function getActionNotFoundRequest(): string
    {
        return $this->actionNotFoundRequest;
    }

    /**
     * @return string
     */
    public function getActionNotPermission(): string
    {
        return $this->actionNotPermission;
    }

    /**
     * @return array
     */
    public function getActions(): array
    {
        return $this->actions;
    }

    /**
     * @return array
     */
    public function getActionPaths(): array
    {
        return $this->actionPaths;
    }
}